<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子30-JS进阶（二）</title>
    </head>

    <body class="cols">
        <pre>
            <code>
                    // 例子30

                    //方式一
                    function Person() {}

                    Person.prototype.getName = function() {}
                    Person.prototype.getAge = function() {}
                    Person.prototype.sayHello = function() {}
            </code>
        </pre>
        <pre>
            <code>

                    //方式二
                    function Person() {}

                    Person.prototype = {
                        constructor: Person,
                        getName: function() {},
                        getAge: function() {},
                        sayHello: function() {}
                    }
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/30.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>